package com.yisu.auction.ewf.common.mq;

import com.alibaba.fastjson.serializer.BooleanArraySerializer;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;

/**
 * Created by Administrator on 2016-12-19.
 */
public class MessageQueueAPI {
    public void SetMessage(String groupName, String ip, String topic, String tag, String message) throws MQClientException,
            InterruptedException {
        DefaultMQProducer producer = new DefaultMQProducer(groupName);
        producer.setNamesrvAddr(ip);
        producer.start();
        try {
            Message msg = new Message(topic,// topic
                    tag,// tag
                    message.getBytes());// body
            SendResult sendResult = producer.send(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        producer.shutdown();
    }
}
